package com.android.example.storage;

import android.os.Bundle;
import android.widget.ImageView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class MainActivity2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main2);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        //一张图片代码
        //ImageView imageView = findViewById(R.id.imageView);
        //imageView.setImageResource(R.drawable.jibenyong);
        // 其中 R.drawable.image_name 是图片资源的名称

        //使用数组或集合存储图片资源
        int[] imageResources = {R.drawable.jibenyong, R.drawable.jbyf_two, R.drawable.jb};

        for (int imageResource : imageResources) {
            ImageView imageView = findViewById(R.id.imageView);
            imageView.setImageResource(imageResource);
            try {
                // 延时 1 秒
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        //使用 List 集合遍历图片：
/*        List<Integer> imageResources = new ArrayList<>();
        imageResources.add(R.drawable.jibenyong);
        imageResources.add(R.drawable.jbyf_two);
        imageResources.add(R.drawable.jb);

        for (int imageResource : imageResources) {
            ImageView imageView = findViewById(R.id.imageView);
            imageView.setImageResource(imageResource);
        }*/

    }
}